console.log(1234);
//1

function Counts(all:string,word:string[]):number{
let sum:number=0
word.forEach((wordItem)=>{
    const narr=wordItem.split('')
    if(narr.every((item)=>all.indexOf(item)!==-1)){
        sum++
    }
})
return sum
}

console.log(Counts('abc',['1','2','3','4','5','6','7']));

//2
function sea(url:string){
const str=url.split('?')[1]
const par=str.split('$')
console.log(par);
let obj={}
par.forEach((item:string)=>{
    const key=item.split('=')[0]
    const value=item.split('=')[1]
    const newobj={
        [key]:value
    }
    console.log(newobj);
    console.log(obj);
    obj={
        ...obj,...newobj
    }
    
})
return obj
}
console.log(sea('http://example.com/index.html?a=1&b=2&c=3&d'));

//3
function fun(pri:number[]){
let pro=0;
for (let i = 0; i <pri .length; i++) {
    let tmp=pri[i]=pri[i-1]
    if(tmp>0){
        pro+=tmp
    }
}
return pro
}
console.log(fun([2,3,4,5,6]));


//4
function sin(nums:number[]){
let num=-1;
for (let i = 0; i <nums .length; i++) {
    if(nums.indexOf(nums[i])==nums.lastIndexOf(nums[i])){
num=nums[i]
    }
}
return num
}
console.log(sin([2,3,4,5,8]));

//5
function flat<T>(arr:Array<T>,k=1):Array<T>{
let narr:Array<T>=[]
arr.forEach(element => {
    if(Array.isArray(element)&&k>=1){
        narr=narr.concat(flat(element,k-1))
    }else{
        narr=narr.concat(element)
    }
});
return narr
}
console.log(flat([1,[2,3,4],[5,6,[7]]]));
